<?php

	require '../conn.php';
	$limit = 10;
	$page = 1;
	
	if ($_REQUEST['limit'] != '') {
		$limit = $_REQUEST['limit'];
	}
	if ($_REQUEST['page'] != '')
	{
		$page = $_REQUEST['page'];
	}
	if ($_REQUEST['shopid'] != '') {
		$shopid = $_REQUEST['shopid'];
	}
	else 
	{
		echo "{\"error\":1,\"message\":\"无店铺id\"}";
		exit;		
	}
	
	$query = "SELECT comment_id,content,comments.createtime,nickname FROM comments,user WHERE comments.uid=user.uid and shop_id=".$shopid." order by comment_id desc limit ".($page - 1)*$limit .", $limit";
	$result = mysql_query($query);
	$arr = array();
	while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{
		$arr[] = $row;
	}
	
	$json_str = json_encode($arr);
	echo '{"comments":'.$json_str.'}';
?>
